import React, {useEffect} from 'react';
import {View, Text, StyleSheet} from 'react-native';
import {useNavigation} from '@react-navigation/native';
import {getToken} from '../../utils/Authority';

const FirstScreen = () => {
  const navigation = useNavigation();
  useEffect(() => {
    // navigation.replace('PaySure');
    const _fn = async () => {
      const token = await getToken();
      if (token) {
        navigation.replace('Tab');
      } else {
        navigation.replace('Login');
      }
    };
    _fn();
  }, [navigation]);

  return (
    <View style={styles.container}>
      <Text>加载中。。。</Text>
    </View>
  );
};

const styles = StyleSheet.create({
  container: {
    flex: 1,
    alignItems: 'center',
    justifyContent: 'center',
  },
});

export default FirstScreen;
